<?php
/**
 * Created by PhpStorm.
 * User: chang
 * Date: 2019/4/1
 * Time: 10:09
 */

namespace App\Http\Model;


use Illuminate\Database\Eloquent\Model;

class RoomMusic extends Model
{
    protected $table = 'room_music';
    
    /**
     * 新增背景音乐
     * @param int $roomId
     * @param string $musicName
     * @param string $musicAuthor
     * @return int
     */
    public function createdRoomMusic(int $roomId, string $musicName, string $musicAuthor){
        $model = new RoomMusic;
        $model->room_id = $roomId;
        $model->music_name = $musicName;
        $model->music_author = $musicAuthor;
        return $model->save();
    }
    
    /**
     * 背景音乐
     * @param int $roomId
     * @return mixed
     */
    public function getRoomMusicListByRoomId(int $roomId){
        return RoomMusic::where(['room_id' => $roomId])->get(['room_id','music_name','music_author']);
    }
}